--[[ 编码: WMS-04-12 名称: 查询面板-仓库变化后 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: WarehouseChange 功能: 需要设置 库区下拉列表 的变化 更改记录: --]] json = require ("json") mobox = require ("OILua_JavelinExt") m3 = require("oi_base_mobox") function WarehouseChange( strLuaDEID ) local nRet, strRetInfo local parameter = {} local attrs -- 获取查询面板里的输入的仓库编码属性 nRet, parameter = m3.GetSysInputParameter( strLuaDEID ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 失败! "..attrs ) end attrs = m3.KeyValueAttrsToObjAttr( parameter ) local wh_code = lua.Get_StrAttrValue( attrs.S_WH_CODE ) if ( wh_code == '' or wh_code == nil ) then return end -- 查询仓库里的库区编码 local strCondition local strOrder = 'S_CODE' strCondition = "S_WH_CODE = '"..wh_code.."'" nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Area", strCondition, strOrder,"S_CODE" ) if (nRet ~= 0) then error( "获取【库区】信息失败! " .. strRetInfo) end local choice_items = {} if ( strRetInfo ~= '' ) then local area = {} local n, nCount local success local attrs success, area = pcall( json.decode, strRetInfo) if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【库区】信息失败! 非法的JSON格式!"..area ) end nCount = #area -- 组织下拉列表选项 for n = 1, nCount do attrs = area[n].attrs table.insert( choice_items, attrs[1].value ) end end local action = { { action_type = "set_dlg_attr", value = { { attr = "S_AREA_CODE", value = "", choice_list = choice_items } } }, { action_type = "click_query_button", value = "" } } nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action ) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end end